//
//  ViewControllerBase.m
//  Wedding fantastic
//
//  Created by ZLM on 15/6/29.
//  Copyright (c) 2015年 dllo. All rights reserved.
//

#import "ViewControllerBase.h"

@interface ViewControllerBase ()

@end

@implementation ViewControllerBase
-(void)dealloc{
    [_myTableView release];
    [_allArr release];
    [_buttonName release];
    [_model1Array release];
    [_shangJiaModelArray release];
    [_HUD release];
    [_myCell release];
    [super dealloc];
}
- (void)viewDidLoad {
    [super viewDidLoad];
    // Do any additional setup after loading the view.
    // 回到顶部button
    UIButton *button = [UIButton buttonWithType:UIButtonTypeCustom];
    button.frame = CGRectMake(300 * kWidth / 375, 450 * kHeight / 667, 35 * kWidth / 375, 35 * kHeight / 667);
    [button setBackgroundImage:[UIImage imageNamed:@"backTop"] forState:UIControlStateNormal];
    button.alpha = 0.6;
    [self.view addSubview:button];
    [button addTarget:self action:@selector(backTop:) forControlEvents:UIControlEventTouchUpInside];
    
    self.myTableView = [[UITableView alloc]initWithFrame:CGRectMake(0, 64+50*kHeight/667, self.view.frame.size.width, kHeight-49-64)];
    self.myTableView.backgroundColor = [UIColor whiteColor];
    
    self.myTableView.tableHeaderView.hidden = YES;
    [self.view addSubview:self.myTableView];
    self.myTableView.delegate = self;
    self.myTableView.dataSource = self;
    [self.myTableView release];
    
    self.allArr = [NSMutableArray array];
//    婚礼策划数组
    NSMutableArray *Arr1 = [NSMutableArray array];
//    婚礼策划套餐字典
    NSMutableDictionary *VC1Dic1 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:15:45Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=2&commodity_type=0&page=1" forKey:@"套餐"];
//   婚礼策划案例字典
    NSMutableDictionary *VC1Dic2 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:15:45Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=2&commodity_type=1&page=1" forKey:@"案例"];
//    婚礼策划商家字典
    NSMutableDictionary *VC1Dic3 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v1/api/app/merchants.json?per_page=20&property=2&sort=default&page=1" forKey:@"商家"];
    [Arr1 addObject:VC1Dic1];
    [Arr1 addObject:VC1Dic2];
    [Arr1 addObject:VC1Dic3];
//    婚纱摄影数组
    NSMutableArray *Arr2 = [NSMutableArray array];
//   婚纱摄影套餐数组
    NSMutableDictionary *VC2Dic1 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:27:32Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=6&commodity_type=0&page=1" forKey:@"套餐"];
//   婚纱摄影案例字典
    NSMutableDictionary *VC2Dic2 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:29:30Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=6&commodity_type=1&page=1" forKey:@"案例"];
//   商家字典
    NSMutableDictionary *VC2Dic3 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v1/api/app/merchants.json?per_page=20&property=6&sort=default&page=1" forKey:@"商家"];
    [Arr2 addObject:VC2Dic1];
    [Arr2 addObject:VC2Dic2];
    [Arr2 addObject:VC2Dic3];
//    摄影师数组
    NSMutableArray *Arr3 = [NSMutableArray array];
//    套餐字典
    NSMutableDictionary *VC3Dic1 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:35:26Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=7&commodity_type=0&page=1" forKey:@"套餐"];
//    案例字典
    NSMutableDictionary *VC3Dic2 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:35:26Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=7&commodity_type=1&page=1" forKey:@"案例"];
//   商家字典
    NSMutableDictionary *VC3Dic3 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v1/api/app/merchants.json?per_page=20&property=7&sort=default&page=1" forKey:@"商家"];
    [Arr3 addObject:VC3Dic1];
    [Arr3 addObject:VC3Dic2];
    [Arr3 addObject:VC3Dic3];
//    摄像师数组
    NSMutableArray *Arr4 = [NSMutableArray array];
//   套餐字典
    NSMutableDictionary *VC4Dic1 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:41:57Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=8&commodity_type=0&page=1" forKey:@"套餐"];
//    案例字典
    NSMutableDictionary *VC4Dic2 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:41:57Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=8&commodity_type=1&page=1" forKey:@"案例"];
//    商家字典
    NSMutableDictionary *VC4Dic3 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v1/api/app/merchants.json?per_page=20&property=8&sort=default&page=1" forKey:@"商家"];
    [Arr4 addObject:VC4Dic1];
    [Arr4 addObject:VC4Dic2];
    [Arr4 addObject:VC4Dic3];
//   化妆师数组
    NSMutableArray *Arr5 = [NSMutableArray array];
//    套餐字典
    NSMutableDictionary *VC5Dic1 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:44:09Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=9&commodity_type=0&page=1" forKey:@"套餐"];
//   案例字典
    NSMutableDictionary *VC5Dic2 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:44:09Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=9&commodity_type=1&page=1" forKey:@"案例"];
//    商家字典
    NSMutableDictionary *VC5Dic3 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v1/api/app/merchants.json?per_page=20&property=9&sort=default&page=1" forKey:@"商家"];
    [Arr5 addObject:VC5Dic1];
    [Arr5 addObject:VC5Dic2];
    [Arr5 addObject:VC5Dic3];
//    主持热数组
    NSMutableArray *Arr6 = [NSMutableArray array];
// 套餐字典
    NSMutableDictionary *VC6Dic1 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:49:38Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=11&commodity_type=0&page=1" forKey:@"套餐"];
//   案例字典
    NSMutableDictionary *VC6Dic2 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:49:38Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=11&commodity_type=1&page=1" forKey:@"案例"];
//   商家字典
    NSMutableDictionary *VC6Dic3 = [NSMutableDictionary dictionaryWithObject:@"http://www.hunliji.com/v1/api/app/merchants.json?per_page=20&property=11&sort=default&page=1" forKey:@"商家"];
    [Arr6 addObject:VC6Dic1];
    [Arr6 addObject:VC6Dic2];
    [Arr6 addObject:VC6Dic3];
//    NSLog(@"!!!!!!!!!!%@  ~~~~~~~~%@  #######%@",Arr1,Arr2,Arr3);
    
    [self.allArr addObject:Arr1];
    [self.allArr addObject:Arr2];
    [self.allArr addObject:Arr3];
    [self.allArr addObject:Arr4];
    [self.allArr addObject:Arr5];
    [self.allArr addObject:Arr6];
    
    NSLog(@"!!!!!!!!!!!!!%@",self.allArr);
    
//    [self getData];
    
    
//    NSString *urlString = @"http://www.hunliji.com/v2/api/app/works?per_page=20&first_query_time=2015-06-26T01:15:45Z&sort%5Bkey%5D=default&sort%5Border%5D=desc&property=2&commodity_type=0&page=1";
//    
//    [NetworkTool get:urlString body:BodyHTTP httpResult:JSON success:^(id result) {
//        NSLog(@"!!!!!!!!!!!!!!%@,",result);
//        
//    } failure:^(NSError *error) {
//        
//        
//    }];
    
}
- (void)backTop:(UIButton *)button
{
    [self.myTableView setContentOffset:CGPointZero animated:YES];
}
/*-(void)getData{
    
    NSString *urlString = @"";
    NSLog(@"~~~~~~~~~~~~~~~~~~~~~~~~~~%@",self.buttonName);
    
        if ([self.buttonName isEqualToString:@"婚礼策划"]) {
            
//            urlString = ((NSMutableDictionary *)[((NSMutableArray *)[self.allArr objectAtIndex:0]) objectAtIndex:0])  ;
            
        }
        if ([self.buttonName isEqualToString:@"婚纱摄影"]) {
        urlString = ((NSMutableDictionary *)[((NSMutableArray *)[self.allArr objectAtIndex:1]) objectAtIndex:0])[@"套餐"];
    }
                if ([self.buttonName isEqualToString:@"摄影师"]) {
            urlString = ((NSMutableDictionary *)[((NSMutableArray *)[self.allArr objectAtIndex:2]) objectAtIndex:0])[@"套餐"];
        }
        if ([self.buttonName isEqualToString:@"摄像师"]) {
            urlString = [((NSArray *)[self.allArr objectAtIndex:3]) objectAtIndex:0];
        }
        if ([self.buttonName isEqualToString:@"化妆师"]) {
            urlString = [((NSArray *)[self.allArr objectAtIndex:4]) objectAtIndex:0];
        }
        if ([self.buttonName isEqualToString:@"主持人"]) {
            urlString = [((NSArray *)[self.allArr objectAtIndex:5]) objectAtIndex:0];
        }

    
    [NetworkTool get:urlString body:BodyHTTP httpResult:JSON success:^(id result) {
           
            
            NSMutableArray *array = result[@"works"];
            
            self.model1Array = [NSMutableArray array];
            for (NSDictionary *tempDic in array) {
                Model1 *mod = [[Model1 alloc] init];
                [mod setValuesForKeysWithDictionary:tempDic];
                [self.model1Array addObject:mod];
                [mod release];
            }
            [self.myTableView reloadData];
        } failure:^(NSError *error) {
    
    
        }];


}
 */

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
    //取消行选中 效果
    [tableView deselectRowAtIndexPath:indexPath animated:YES];
}
-(NSInteger)numberOfSectionsInTableView:(UITableView *)tableView{
    return 1;
}
-(UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    
    NSString static *cellIdentifier = @"reusedCell";
    self.myCell = [tableView dequeueReusableCellWithIdentifier:cellIdentifier];
    if (self.myCell == nil) {
        self.myCell = [[TaoCanAnLiTableViewCell alloc]initWithStyle:UITableViewCellStyleDefault reuseIdentifier:cellIdentifier];
    }
//    
    TaoCanAnLiModel *mod = [self.model1Array objectAtIndex:indexPath.row];
//    myCell.textLabel.text = mod.title;
    
    //隐藏边框：
    self.myCell.imageV.layer.masksToBounds = YES;
    //边角弧度：
//    self.myCell.imageV.layer.cornerRadius = 20;
//    套餐或案例图片视图赋值
    [self.myCell.imageV sd_setImageWithURL:[NSURL URLWithString:mod.cover_path] placeholderImage:[UIImage imageNamed:@"placeHoderImage"]];
//    套餐或案例标题赋值
    self.myCell.titleLabel.text = mod.title;
    
//   名称赋值
    self.myCell.nameLabel.text = [mod.merchant objectForKey:@"name"];
    //3D效果
    self.myCell.layer.transform = CATransform3DMakeScale(0.3, 0.3, 0.1);
    [UIView animateWithDuration:0.5 animations:^{
        
        self.myCell.layer.transform = CATransform3DMakeScale(1, 1, 0.1);
    }];

    return self.myCell;
}
//行高
-(CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return 260*kHeight/667;
}
//行数
-(NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    
    return self.model1Array.count;
    
}



- (void)didReceiveMemoryWarning {
    [super didReceiveMemoryWarning];
    // Dispose of any resources that can be recreated.
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end
